<?php
/**
 * Created by PhpStorm.
 * User: ASUS
 * Date: 2018/9/28
 * Time: 22:25
 */

namespace Dxadmin\Controller;


class QuestionnaireController extends ComController
{
    /**
     * 数据列表
     */
    public function index(){
        $p=I('request.p',1,'intval');
        $where =array();

        $start_time=I('request.start_time');
        if(!empty($start_time)){
            $where['create_time']=array(
                array('EGT',$start_time)
            );
        }
        $end_time=I('request.end_time');
        if(!empty($end_time)){
            if(empty($where['create_time'])){
                $where['create_time']=array();
            }
            array_push($where['create_time'], array('ELT',$end_time));
        }

        $number=I('request.number');
        if(!empty($number)){
            $where['number'] = $number;
        }

        $number=I('request.mobile');
        if(!empty($number)){
            $where['mobile'] = $number;
        }

        $model = M('app_wxapp_exam_view');
        $pagesize = 10;#每页数量
        $offset = $pagesize*($p-1);//计算记录偏移量
        $count = $model->where($where)->count();

        $list  = $model->where($where)->limit($offset.','.$pagesize)->select();

        $page	=	new \Think\Page($count,$pagesize);
        $page = $page->show();
        $this->assign('list',$list);
        $this->assign('page',$page);
        $this->assign($_REQUEST);
        $this -> display();
    }

    /**
     * 详情
     */
    public function detail(){
        $id=I('get.id');
        $info=M('app_wxapp_exam_view')->where(array('id'=>$id))->find();
        $detail=M('app_wxapp_exam_detail')->where(array('exam_id'=>$id))->select();
        $this->assign('info',$info);
        $this->assign('detail',$detail);
        $this -> display();
    }

}